package demo1;

import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        Student student1=new Student("zhangsan",10);
        Student student2=new Student("wangwu",10);
        System.out.println(student1.equals(student2));
    }
    public static void main2(String[] args) {
        Student[] students=new Student[4];
        students[0]=new Student("zhangsan ",6);
        students[1]=new Student("lisi ",8);
        students[2]=new Student("wangwu ",10);
        students[3]=new Student("laoliu ",9);
        System.out.println("排序前"+Arrays.toString(students));
        NameComparator nameComparator=new NameComparator();
        int ret=nameComparator.compare(students[0],students[2]);
        System.out.println(ret);
    }

    public static void main1(String[] args) {
        Student[] students=new Student[4];
        students[0]=new Student("zhangsan ",6);
        students[1]=new Student("lisi ",8);
        students[2]=new Student("wangwu ",10);
        students[3]=new Student("laoliu ",9);
        System.out.println("排序前"+Arrays.toString(students));
        NameComparator nameComparator=new NameComparator();
        AgeComparator ageComparator=new AgeComparator();
        Arrays.sort(students,nameComparator);
        System.out.println("name排序后"+Arrays.toString(students));
        Arrays.sort(students,ageComparator);
        System.out.println("age排序后"+Arrays.toString(students));
    }
}

